<%@ page import="com.alibaba.fastjson.JSON" %>
<%@ page import="top.sehnsucht.vo.Result" %>
<%@ page import="org.apache.log4j.Logger" %>
<%@ page import="top.sehnsucht.dao.ExcelDao" %>
<%@ page import="top.sehnsucht.dao.impl.ExcelDaoImpl" %>
<%@ page import="top.sehnsucht.service.ExcelService" %>
<%@ page import="top.sehnsucht.service.impl.ExcelServiceImpl" %>
<%@ page contentType="text/html;charset=UTF-8" language="java" %>
<%
    Logger logger = Logger.getLogger(this.getClass());

    response.setHeader("Content-Type", "application/json;charset=UTF-8");//注意加上这一句

    Result result = new Result();
    result.setCode(0);
    result.setCount(1L);

    //清空session
    request.getSession().getServletContext().setAttribute("allPicUrls", "");
    request.getSession().getServletContext().setAttribute("allFilename", "");

    ExcelDao dao = new ExcelDaoImpl();
    ExcelService service = new ExcelServiceImpl(dao);

    String id = request.getParameter("id");

//    System.out.println(service.showTable());
    //todo 需要让他能够下载,需要先从数据库中取出数据然后生成xls文件,然后根据网页传过来的name读取文件然后可下载
    //todo dao需要几个函数,查找所有表并选择name,找到name后进行数据库对应的excel文件的生成,然后download根据地址跳转,进行下载

    //todo dao的查找表并返回json数据 2. 选择name并生成excel,存放在文件中

    //todo 剩下生成excel和在download页面生成xls

    String json = JSON.toJSONString(service.showTable());

    System.out.println(json);

    out.println("{\"code\":" + result.getCode() + ",\"msg\":\"\",\"count\":" + result.getCount() + ",\"data\":" + json + "}");

%>

